package client;

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Queue;

/**
 * This class is considered "priority" because its messages are drawn on top of
 * all other screen elements.
 * 
 * @author Robz
 * 
 */
public class PriorityMessageQueue implements Queue<String> {

	private static List<Message> messages;
	private static int currentTime;
	
	public PriorityMessageQueue() {
		messages = new ArrayList<Message>();
	}

	private static class Message {

		private String data;
		private int creationTime;

		private Message(String data, int creationTime) {
			this.data = data;
			this.creationTime = creationTime;
		}

	}

	public void paint(Graphics g, int gameTime) {
		currentTime = gameTime;
		
		int y = 0;
		synchronized (messages) {
			for (Iterator<Message> it = messages.iterator(); it.hasNext();) {
				y += 25;
				Message m = (Message) it.next();
				g.setColor(Color.MAGENTA);
				g.fillRect(0, 375 - y, 400, 25);
				g.setColor(Color.BLACK);
				g.drawString(m.data, 100, 390 - y);
				if (currentTime >= m.creationTime + 200) {
					it.remove();
				}
			}
		}
	}

	public static void addMessage(String data) {
		Message m = new Message(data, currentTime);
		messages.add(m);
	}

	@Override
	public boolean addAll(Collection<? extends String> arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void clear() {
		// TODO Auto-generated method stub

	}

	@Override
	public boolean contains(Object arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean containsAll(Collection<?> arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean isEmpty() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public Iterator<String> iterator() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean remove(Object arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean removeAll(Collection<?> arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean retainAll(Collection<?> arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public int size() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public Object[] toArray() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public <T> T[] toArray(T[] arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean add(String arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public String element() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean offer(String arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public String peek() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String poll() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String remove() {
		// TODO Auto-generated method stub
		return null;
	}

}
